package com.eling.elcms.travel.webapp.controller;

import com.eling.elcms.core.dao.hibernate.search.SearchCondition;
import com.eling.elcms.core.webapp.controller.BaseFormController;
import com.eling.elcms.core.webapp.controller.Msg;
import com.eling.elcms.core.webapp.spring.ModelFilling;
import com.eling.elcms.travel.model.ApprovalProcess;
import com.eling.elcms.travel.service.IApprovalProcessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class ApprovalProcessController extends BaseFormController{

	@Autowired
	IApprovalProcessService approvalProcessService;
	
	@RequestMapping("/api/approvalprocess/save")
	@ResponseBody
	public ApprovalProcess save(@ModelAttribute@ModelFilling ApprovalProcess approvalProcess){
		return approvalProcessService.save(approvalProcess);
	}
	
	
	@RequestMapping("/api/Approvalprocess/{pkApprovalProcess}/delete")
	@ResponseBody
	public Msg delete( @PathVariable Long pkApprovalProcess){
		approvalProcessService.remove(pkApprovalProcess);
		return new Msg("删除成功");
	}
	
	
	@RequestMapping("/api/approvalprocess/query")
	@ResponseBody
	public List<ApprovalProcess> query(@ModelAttribute ApprovalProcess cond){
		return approvalProcessService.query(cond);
	}
	
	@RequestMapping("/api/approvalprocess/search*")
	@ResponseBody
	public List<ApprovalProcess> search(@ModelAttribute SearchCondition sc ){
		return approvalProcessService.search(sc);
	}
}
